#ifndef _MEDIA_SERVICE_H
#define _MEDIA_SERVICE_H

/* media capabilities */

char media_caps[] = 
{
	CONFIG_NUM,//max profiles number
	FALSE,//rtp-multicast
	FALSE,//rtp-tcp
	FALSE,//rtp-rtsp-tcp
	FALSE //nonaggrerate-control
};
/*
 * Profile params info
 *
 */
typedef enum 
{
	PF_NAME = 0,
	PF_TOKEN,
	PF_FIXED,
	PF_VSTOKEN,
	PF_ASTOKEN,
	PF_VETOKEN,
	PF_AETOKEN,
	PF_VATOKEN,
	PF_PTZTOKEN,
	PF_MDTOKEN,
	PF_AOTOKEN,
	PF_ADTOKEN,

	PF_MAX_POS
}PROFILE_MEM_POS;

static int profile_num = 2;
static char *profiles[CONFIG_NUM][12]; //= {
#if 0
	{
		"NetransProfile",//name
		"NetransProfile",//token
		"false",//fixed
		"vsource_1",//video source token
		"asource_1",//audio source token
		"vencoder_1",//video encoder token
		"aencoder_1",//audio encoder token
		"vanalytics_1",//video analytics token
		"ptz_1",//ptz token
		"meta_1",//metadata token
		//extension: audio output, audio decoder
		NULL,
		NULL
	},
	{
		"RecordProfile",
		"RecordProfile",
		"false",
		"vsource_1",
		"asource_1",
		"vencoder_2",
		"aencoder_1",
		"vanalytics_1",
		"ptz_1",
		"meta_1",

		NULL,
		NULL
	}
};
#endif

/*
 * video encoder configurations
 */
typedef enum VEncoder_Config_Pos
{
	VE_PCMPNUM = 0,
	VE_PCMPLIST,

	VE_NAME,
	VE_USECOUNT,
	VE_TOKEN,
	VE_ENCODE,
	VE_RESOL,
	VE_QUALITY,
	VE_RATE,
	VE_MPEG4,
	VE_H264,
	VE_MULTICAST,
	VE_SESSTIME,
	VE_ANYSIZE,
	VE_ANY,
	VE_ANYATTR,

	VE_MAX_POS
}VE_CONFIG_POS;
static int ve_config_num = 2;
static char *ve_configurations[CONFIG_NUM][16];
#if 0
= {
	{
		"1",//the number of compatible profile
		"NetransProfile;",//compatible profile list

		"vencoder_1",//name
		"1",//usercount,read-only
		"vencoder_1",//token
		"1",//encodeing, JPEG=0,MPEG4=1,H264=2
		"1280;720;",//resolution:width;height;
		"7",//quality, 1-10
		"25;1;2048;",//video rate control
		"15;0;",//mpeg4 configuration: govlength;profile:sp=0,asp=1
		NULL, //h264 configuration
		"ipv4,0.0.0.0;554;60;true;0;",//multicast configuration: ip;port;ttl;autostart;__size;__any;
		"720000",//session timeout,unit:ms --> PT12M
		"0",//__size
		NULL, //__any
		NULL, //__anyAttribute
	},
	{
		"1",//the number of compatible profile
		"RecordProfile;",//compatible profile list

		"vencoder_2",//name
		"1",//usercount,read-only
		"vencoder_2",//token
		"2",//encodeing, JPEG=0,MPEG4=1,H264=2
		"1280;720;",//resolution
		"7",//quality, 1-10
		"25;1;1024;",//video rate control
		NULL,//mpeg4 configuration: govlength;profile:sp=0,asp=1
		"10;0;", //h264 configuration:govlength;profile:baseline=0,main=1,extended=2,high=3
		"ipv4,0.0.0.0;554;60;true;0;",//multicast configuration: ip;port;ttl;autostart;__size;__any;
		"720000",//session timeout
		"0",//__size
		NULL, //__any
		NULL, //__anyAttribute
	}
};
#endif
/*
 * video source configuration
 */
typedef enum VSource_Config_Pos
{
	VS_PCMPNUM = 0,
	VS_PCMPLIST,

	VS_NAME,
	VS_USECOUNT,
	VS_TOKEN,
	VS_SRCTOKEN,
	VS_BOUNDS,
	VS_ANYSIZE,
	VS_ANY,
	VS_ANYATTR,

	VS_MAX_POS
}VS_CONFIG_POS;
static  int vs_config_num = 1;
static  char *vs_configurations[CONFIG_NUM][10];
#if 0
= {
	{
		"2",//the number of compatible media profile : 0 -- all compatible
		"NetransProfile;RecordProfile;", //compatible media profile list

		"vsource_1",//name
		"2",//usecount
		"vsource_1",//token
		"vsource_1",//source token
		"1;1;1280;720;",//Bounds: x;y;width;hieght;		
		"0", //__size
		NULL,
		NULL
	}
};
#endif
//video output
typedef enum 
{
	VO_NAME = 0,
	VO_USECOUNT,
	VO_TOKEN,
	VO_OPTOKEN,
	VO_ANYSIZE,
	VO_ANY,
	VO_ANYATTR,

	VO_MAX_POS
}VO_CONFIG_POS;
static int vo_config_num = 1;
static char *vo_configurations[CONFIG_NUM][7];  
#if 0
= {
	{
		"voutput_1", //name
		"1",//usecount
		"voutput_1",//token
		"voutput_1",//output token <physical device>
		"0", //__size
		NULL,
		NULL
	}
};
#endif
//audio source
typedef enum ASource_Config_Pos
{
	AS_PCMPNUM = 0,
	AS_PCMPLIST,

	AS_NAME,
	AS_USECOUNT,
	AS_TOKEN,
	AS_SRCTOKEN,
	AS_ANYSIZE,
	AS_ANY,
	AS_ANYATTR,

	AS_MAX_POS
}AS_CONFIG_POS;
static  int as_config_num = 1;
static  char *as_configurations[CONFIG_NUM][9];
#if 0
= {
	{
		"0",//the number of compatible profile :0 -- all compatible
		"*",//the compatible profile list

		"asource_1",//name
		"1",//usecount
		"asource_1",//token
		"asource_1",//source token
		"0", //__size
		NULL,
		NULL
	}
};
#endif
//audio ouput
typedef enum 
{
	AO_PCMPNUM = 0,
	AO_PCMPLIST,

	AO_NAME,
	AO_USECOUNT,
	AO_TOKEN,
	AO_OPTOKEN,
	AO_SNDPRI,
	AO_OPLEVL,
	AO_ANYSIZE,
	AO_ANY,
	AO_ANYATTR,

	AO_MAX_POS
}AO_CONFIG_POS;
static  int ao_config_num = 1;
static  char *ao_configurations[CONFIG_NUM][11];
#if 0
= {
	{
		"0",//the number of compatible profile: 0 -- all compatible
		"*",//the compatible profile list

		"aoutput_1", //name
		"1",//usecount
		"aoutput_1",//token
		"aoutput_1",//output token <physical device>
		"www.onvif.org/ver20/HalfDuplex/Auto",//SendPrimacy:direction
		"80",//OutputLevel: volume setting
		"0", //__size
		NULL,
		NULL
	}
};
#endif
/*
 * audio encoder configurations
 */
typedef enum AEncoder_Config_Pos
{
	AE_PCMPNUM = 0,
	AE_PCMPLIST,

	AE_NAME,
	AE_USECOUNT,
	AE_TOKEN,
	AE_ENCODE,
	AE_BITRATE,
	AE_SAMRATE,
	AE_MULTICAST,
	AE_SESSTIME,
	AE_ANYSIZE,
	AE_ANY,
	AE_ANYATTR,

	AE_MAX_POS
}AE_CONFIG_POS;
static  int ae_config_num = 1;
static char *ae_configurations[CONFIG_NUM][13];
#if 0
= {
	{
		"0",//the number of compatible profile: 0 -- all compatible
		"*",//compatible profile list

		"aencoder_1",//name
		"2",//usecount
		"aencoder_1",//token
		"0",//audio encoding:G711 - 0,G726 - 1,AAc - 3
		"32",//bitrate,unit:kbps
		"80",//samplerate,unit:kHz
		"ipv4,0.0.0.0;554;60;true;0;",//multicast configuration: ip;port;ttl;autostart;__size;__any;
		"720000",//session timeout,unit:ms --> PT12M
		"0",//__size
		NULL, //__any
		NULL, //__anyAttribute
	}
};
#endif
/*
 * audio decoder configurations
 */
typedef enum
{
	ADEC_PCMPNUM = 0,
	ADEC_PCMPLIST,

	ADEC_NAME,
	ADEC_USECOUNT,
	ADEC_TOKEN,
	ADEC_ANYSIZE,
	ADEC_ANY,
	ADEC_ANYATTR,

	ADEC_MAX_POS
}ADEC_CONFIG_POS;
static  int adec_config_num = 1;
static char *adec_configurations[CONFIG_NUM][8];
#if 0
= {
	{
		"0",//the number of compatible profile: 0 -- all compatible
		"*", //compatible profile list

		"adecoder_1",//name
		"0",//usecount
		"adecoder_1",//token
		"0",//any size
		NULL,//any
		NULL//__anyAttribute
	}
};
#endif

/*
 * video analytics configurations
 */
typedef enum
{
	VA_PCMPNUM = 0,
	VA_PCMPLIST,

	VA_NAME,
	VA_USECOUNT,
	VA_TOKEN,
	VA_AECONF,
	VA_RECONF,
	VA_ANYSIZE,
	VA_ANY,
	VA_ANYATTR,
	
	VA_MAX_POS
}VA_CONFIG_POS;
static int va_config_num = 1;
static char *va_configurations[CONFIG_NUM][10];


/*
 * metadata configurations
 */
typedef enum
{
	META_PCMPNUM = 0,
	META_PCMPLIST,

	META_NAME,
	META_USECOUNT,
	META_TOKEN,
	META_PTZSTAT,
	META_EVENT,
	META_ANALY,
	META_MULTICAST,
	META_SESSTIME,
	META_ANYSIZE,
	META_ANY,
	META_ANYATTR,

	META_MAX_POS
}META_CONFIG_POS;
static int meta_config_num = 1;
static char *meta_configurations[CONFIG_NUM][13];


//==== Configuration Options =======
//video source
typedef enum
{
	OPT_VS_VSCNUM = 0,
	OPT_VS_VSCLIST,
	OPT_VS_PCMPNUM,
	OPT_VS_PCMPLIST,

	OPT_VS_BRANGE,
	OPT_VS_SVSTA,
	OPT_VS_VSTAS,
	OPT_VS_EXT,
	OPT_VS_ANYATTR,

	OPT_VS_MAX_POS
}OPT_VS_POS;
static int vsconfig_options_num = 1;
static char *vsconfig_options[CONFIG_NUM][9];
#if 0
= {
	{
		"1",//size of intened for video source configuration
		"vsource_1;",//video source configuration intended for
		"0",//size of media profile compatible: 0 -- without compatible consideration
		"*",//compatible media profile list

		"0,1280;0,720;320,1280;240,720;", //Bounds range:x,y,width,height
		"1", //__sizeVideoSourceTokensAvailable
		"vsource_1;", //VideoSourceTokensAvailable
		NULL, //extension
		NULL //any attribute
	}
};
#endif

//video encoder
typedef enum
{
	OPT_VE_VECNUM = 0,
	OPT_VE_VECLIST,
	OPT_VE_PCMPNUM,
	OPT_VE_PCMPLIST,

	OPT_VE_QRANGE,
	OPT_VE_JPEG,
	OPT_VE_MPEG,
	OPT_VE_H264,
	OPT_VE_EXT,
	OPT_VE_ANYATTR,

	OPT_VE_MAX_POS
}OPT_VE_POS;
static int veconfig_options_num = 3;
static char *veconfig_options[CONFIG_NUM][10];
#if 0
= {
	{
		"1",//size of intened for video encoder configuration
		"vencoder_1;",//video encoder configuration intended for
		"1",//size of media profile compatible: 0 -- without compatible consideration
		"NetransProfile;",//compatible media profile list

		"1,10;", //Quality range:min,max
		"1;1280,720;1,30;1,15;", //JPEG options:resol-size;resolus;framerate range;encodinginterval range;
		//MPEG4 options:resol-size;resolus;GovLengthRange;FrameRateRange;EncodingIntervalRange;profile-szie;profile level;
		"1;1280,720;1,15;1,25;1,10;1;0;", 
	    NULL, //H264	
		NULL, //extension
		NULL //any attribute
	},
	{
		"1",//size of intened for video encoder configuration
		"vencoder_2;",//video encoder configuration intended for
		"1",//size of media profile compatible: 0 -- without compatible consideration
		"RecordProfile;",//compatible media profile list

		"1,10;", //Quality range:min,max
		"1;1280,720;1,30;1,15;", //JPEG options:resol-size;resolus;framerate range;encodinginterval range;
		NULL,//MPEG4
		"1;1280,720;1,15;1,30;1,10;2;0;1;", //H264 options:resol-size;resolus;GovLengthRange;FrameRateRange;EncodingIntervalRange;profile-szie;profile level;
		NULL, //extension
		NULL //any attribute
	},
	{
		"2",//size of intened for video encoder configuration
		"vencoder_1;vencoder_2;",//video encoder configuration intended for
		"0",//size of media profile compatible: 0 -- without compatible consideration
		"*",//compatible media profile list

		"1,10;", //Quality range:min,max
		"1;1280,720;1,30;1,15;", //JPEG options:resol-size;resolus;framerate range;encodinginterval range;
		"1;1280,720;1,15;1,25;1,10;1;0;", //MPEG4 options:resol-size;resolus;GovLengthRange;FrameRateRange;EncodingIntervalRange;profile-szie;profile level;
		"1;1280,720;1,15;1,30;1,10;2;0;1;", //H264 options:resol-size;resolus;GovLengthRange;FrameRateRange;EncodingIntervalRange;profile-szie;profile level;
		NULL, //extension
		NULL //any attribute
	}
};
#endif

//audio source
typedef enum 
{
	OPT_AS_ASCNUM = 0,
	OPT_AS_ASCLIST,
	OPT_AS_PCMPNUM,
	OPT_AS_PCMPLIST,

	OPT_AS_SITA,
	OPT_AS_ITALIST,
	OPT_AS_EXT,

	OPT_AS_MAX_POS
}OPT_AS_POS;
static int asconfig_options_num = 1;
static char *asconfig_options[CONFIG_NUM][7];
#if 0
= {
	{
		"1",//size of audio source configuration intended for
		"asource_1;",//audio source configuration list
		"0",//size of media profile compatible
		"*",//mediao profile list

		"1",//size of input tokens available
		"asource_1;",//input token available
		NULL
	}
};
#endif

//audio encoder
typedef enum 
{
	OPT_AE_AECNUM = 0,
	OPT_AE_AECLIST,
	OPT_AE_PCMPNUM,
	OPT_AE_PCMPLIST,

	OPT_AE_SIZE,
	OPT_AE_G711,
	OPT_AE_G726,
	OPT_AE_AAC,
	OPT_AE_ANYATTR,

	OPT_AE_MAX_POS
}OPT_AE_POS;
static int aeconfig_options_num = 1;
static char *aeconfig_options[CONFIG_NUM][9];
#if 0
= {
	{
		"1",//size of audio encoder configuration intended for
		"aencoder_1;",//audio encoder configuration list
		"0",//size of media profile compatible
		"*",//mediao profile list

		"2",//size of options
		"0;5,16,32,48,96;4,8,16,32,48;",//G711 options
		"1;5,16,32,48,96;4,8,16,32,48;",//G726 options
		NULL,//AAC options
		NULL //any attribute
	}
};
#endif

//audio decoder
typedef enum 
{
	OPT_ADEC_ADECNUM = 0,
	OPT_ADEC_ADECLIST,
	OPT_ADEC_PCMPNUM,
	OPT_ADEC_PCMPLIST,

	OPT_ADEC_AAC,
	OPT_ADEC_G711,
	OPT_ADEC_G726,
	OPT_ADEC_EXT,
	OPT_ADEC_ANYATTR,

	OPT_ADEC_MAX_POS
}OPT_ADEC_POS;
static int adeconfig_options_num = 1;
static char *adeconfig_options[CONFIG_NUM][9];
#if 0
= {
	{
		"1",//size of audio decoder configuration intended for
		"adecoder_1;",//audio decoder configuration list
		"0",//size of media profile compatible
		"*",//mediao profile list

		NULL,//AAC options
		"5,16,32,48,96;4,8,16,32,48;",//G711 options: Bitrate list;sample rate list;
		"5,16,32,48,96;4,8,16,32,48;",//G726 options
		NULL,//extension
		NULL //any attribute
	}
};
#endif

//audio output
typedef enum
{
	OPT_AO_AOCNUM = 0,
	OPT_AO_AOCLIST,
	OPT_AO_PCMPNUM,
	OPT_AO_PCMPLIST,

	OPT_AO_SOTA,
	OPT_AO_OTS,
	OPT_AO_SSPA,
	OPT_AO_SPO,
	OPT_AO_OLR,
	OPT_AO_ANYSIZE,
	OPT_AO_ANY,
	OPT_AO_ANYATTR,

	OPT_AO_MAX_POS
}OPT_AO_POS;
static int   aoconfig_options_num = 1;
static char * aoconfig_options[CONFIG_NUM][12];
#if 0
= {
	{
		"1",//size of audio output configuration
		"aoutput_1;",//audio output configuration list intended for
		"0", //size of media profile compatible
		"*",//media profile compatible list

		"1", //__sizeOutputTokensAvailable
		"aoutput_1;", //output tokens
		"3",//size of send primacy options
		"www.onvif.org/ver20/HalfDuplex/Server;www.onvif.org/ver20/HalfDuplex/Client;www.onvif.org/ver20/HalfDuplex/Auto;",//send primacy options
		"0,100;", //output level range:min,manx;
		"0", //any size
		NULL,
		NULL
	}
};
#endif

typedef enum
{
	VE_INST_VSCFG = 0,
	VE_INST_TOTNUM,
	VE_INST_JPEG,
	VE_INST_H264,
	VE_INST_MPEG4,

	VE_INST_MAX
}VE_INST_POS;
static  int ve_instances_num = 1;
static  char *ve_instances[CONFIG_NUM][5];
#if 0
= {
	{
		"vsource_1",//video source configuration token
		"2", //Total number
		"1",//JPEG number
		"2",//H264 number
		"0"//MJPEG number
	}
};
#endif

static char *rtsp_uri[CONFIG_NUM] = 
{
	"rtsp://192.168.0.141/para.m4e",
	"rtsp://192.168.0.141/para.m4e",
	"rtsp://192.168.0.141/slamtv60.264"
};

static char *snapshot_uri[CONFIG_NUM] =
{
	"http://192.168.0.7/images/matrix.jpg",
	"http://192.168.0.7/images/matrix.jpg",
	"http://192.168.0.7/images/matrix.jpg"
};

// media servive specific fault code
typedef enum
{
	TRT_RECV_AUDIONS = 0,
	TRT_RECV_AOUTPUTNS,
	TRT_RECV_ADECNS,
	TRT_RECV_MAXNVTPF,
	TRT_RECV_INCOMCONF,
	TRT_RECV_CONFCFLICT,

	TRT_SEND_PFEXISTS,
	TRT_SEND_NOCONF,
	TRT_SEND_NOPROFILE,
	TRT_SEND_CONFMDY,
	TRT_SEND_INVSTREAMSETUP,
	TRT_SEND_INVMULTISET,
	TRT_SEND_DELFIXEDPF,
	TRT_SEND_VANS,
	TRT_SEND_STREAMCFLICT,

	TRT_SFC_MAX,
}TRT_SFC_POS;
const char *media_spec_fault_code[][5] = 
{
	{"env:Receiver","ter:ActionNotSupported","No audio capability","ter:AudioNotSupported",NULL},
	{"env:Receiver","ter:ActionNotSupported","No audio output capability","ter:AudioOutputNotSupported",NULL},
	{"env:Receiver","ter:ActionNotSupported","No audio decoding capability","ter:AudioDecodingNotSupported",NULL},
	{"env:Receiver","ter:Action","Maximum number reached","ter:MaxNVTProfiles",NULL},
	{"env:Receiver","ter:Action","Configuration not complete","ter:IncompleteConfiguration",NULL},
	{"env:Receiver","ter:Action","Conflict when using new settings","ter:ConfigurationConflict",NULL},
	
	{"env:Sender","ter:InvalidArgVal","Profile token already exists","ter:ProfileExists",NULL},
	{"env:Sender","ter:InvalidArgVal","Configuration token does not exist","ter:NoConfig",NULL},
	{"env:Sender","ter:InvalidArgVal","Profile token does not exist","ter:NoProfile",NULL},
	{"env:Sender","ter:InvalidArgVal","Parameters can not be set","ter:ConfigModify",NULL},
	{"env:Sender","ter:InvalidArgVal","Invalid Stream setup","ter:InvalidStreamSetup",NULL},
	{"env:Sender","ter:InvalidArgVal","Invalid multicast configuration","ter:InvalidMulticastSettings",NULL},
	{"env:Sender","ter:Action","Fixed profile can not be deleted","ter:DeletionOfFixedProfile",NULL},
	{"env:Sender","ter:ActionNotSupported","No video analytics capability","ter:VideoAnalyticsNot-Supported",NULL},
	{"env:Sender","ter:OperationProhibited","Stream conflict","ter:StreamConflict",NULL},

	{NULL,NULL,NULL,NULL,NULL}
};

#endif

